#include <REGX52.H>
#include "Key.h"
#include "Nixie.h"
#include "Delay.h"
#include "Timer0.h"

sbit Motor=P1^0;

unsigned char compare,counter,keyn,speed;

void main()
{
    Timer0_Init();
	while(1)
	{
        keyn=Key();
        if(keyn==1)
        {
            speed++;
            speed%=4;
        }
        if(speed==0){compare=0;}
        if(speed==1){compare=33;}
        if(speed==2){compare=66;}
        if(speed==3){compare=100;}
        nixie(1,speed);
	}
}

void Timer0_Routine() interrupt 1
{
	TL0 = 0x9C;				//设置定时初始值
	TH0 = 0xFF;				//设置定时初始值
    counter++;
    counter%=100;
    if(counter<compare)
    {
        Motor=1;
    }
    else{Motor=0;}
}
